package com.atguigu.exer3;

/*
按理说，类的成员之间是互相独立的，顺序应该是可以随意的
但是，习惯上，我们会按照如下顺序编写：
（1）属性的定义，成员变量
（2）构造器
（3）get/set方法
（4）其他方法
 */
public class ElectricScooter {
    private String scooterId;
    private String brand;
    private double batteryLevel;
    private boolean isAvailable;

    private static int maxSpeed = 25;

    //无参构造
    public ElectricScooter() {
    }

    //有参构造
    public ElectricScooter(String scooterId, String brand, double batteryLevel, boolean isAvailable) {
        this.scooterId = scooterId;
        this.brand = brand;
       // this.batteryLevel = batteryLevel;
        /*if(batteryLevel<0){
            this.batteryLevel = 0;
        }else if(batteryLevel>100){
            this.batteryLevel = 100;
        }else {
            this.batteryLevel = batteryLevel;
        }*/
//        this.setBatteryLevel(batteryLevel);
        setBatteryLevel(batteryLevel);//完全可以省略this.
        this.isAvailable = isAvailable;
    }

    public static int getMaxSpeed() {
        return maxSpeed;
    }

    public static void setMaxSpeed(int maxSpeed) {
        ElectricScooter.maxSpeed = maxSpeed;
    }

    public String getScooterId() {
        return scooterId;
    }

    public void setScooterId(String scooterId) {
        this.scooterId = scooterId;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public double getBatteryLevel() {
        return batteryLevel;
    }

    public void setBatteryLevel(double batteryLevel) {
        if(batteryLevel<0){
            this.batteryLevel = 0;
        }else if(batteryLevel>100){
            this.batteryLevel = 100;
        }else {
            this.batteryLevel = batteryLevel;
        }
    }

    public boolean isAvailable() {
        return isAvailable;
    }

    public void setAvailable(boolean available) {
        isAvailable = available;
    }
}
